{extend name="public/base" /}
{block name="title"}<title>{$Think.lang.list}</title>{/block}
{block name="pjax_container"}

<section class="content-header">

    <h1>{$Think.lang.c_title}{$Think.lang.list}</h1>

</section>

<section class="content">

    <div class="row">

        <div class="col-md-12">

            <div class="box box-primary">

                <div class="box-header with-border">
                    <h3 class="box-title"></h3>
                    <div class="pull-left">
                        {:auth_action(CONTROLLER_NAME.'/create', 'a', lang('create'),['school_id' => $school_id], 'primary', 'sm', 'save')} 
                        {:auth_action(CONTROLLER_NAME.'/delete', 'box', lang('delete'), '', 'danger', 'sm', 'trash')} 
                    </div>

                    <div style="float: right;">

                        <form action="{:search_url('search')}" method="GET" pjax-search="">

                            <div class="input-group input-group-sm col-lg-4" style="float: right;">

                                <input type="text" name="search" class="form-control pull-right" value="{:input('get.search')}" placeholder="搜索名称" />

                                <div class="input-group-btn"><button type="submit" class="btn btn-default sreachs"><i class="fa fa-search"></i></button></div>

                            </div>

                        </form>

                    </div>

                </div>

                <div class="box-body table-responsive">

                    <table class="table table-bordered table-hover table-sort">

                        <tr>

                            <th width="35"><input type="checkbox" class="minimal checkbox-toggle"></th>

                            <th>{$Think.lang.id}{:table_sort('id')}</th>

                            <th>{$Think.lang.name}</th>

                            <th>{$Think.lang.createtime}{:table_sort('createtime')}</th>

                            <th>{$Think.lang.status}{:table_sort('status')}</th>

                            <th width="124">{$Think.lang.action}</th>

                        </tr>

                        {volist name="dataList" id="vo"}

                        <tr>

                            <td><input type="checkbox" name="id[]" value="{$vo.id}" class="minimal"></td>

                            <td>{$vo.id}</td>

                            <td>{$vo.name}</td>

                            <td>{:date('Y-m-d H:i:s',$vo.createtime)}</td>

                            <td><a href="javascript:void(0);" data-id="{$vo.id}" data-field="status" 
                                data-value="{$vo.status}" data-url="{:url('edit', 'id='.$vo['id'])}" 
                                class='editimg fa {if $vo.status == 1 }fa-check-circle text-green{else /}fa-times-circle text-red{/if}'></a></td>

                            <td>{:auth_action(CONTROLLER_NAME.'/edit', 'a', lang('edit'), ['id' => $vo.id,'school_id'=> $school_id])} 
{:auth_action(CONTROLLER_NAME.'/delete', 'box', lang('delete'), $vo.id, 'danger', 'xs', 'trash')} </td>

                        </tr>

                        {/volist}

                    </table>

                </div>

                <div class="box-footer clearfix">

                    {$dataList->render()|raw}

                </div>

            </div>

        </div>

    </div>

</section>

<script type="text/javascript">

$(function(){

    /*ajax页面加载icheck，有该控件的页面才需要*/

    $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({

        checkboxClass: 'icheckbox_minimal-blue',

        radioClass: 'iradio_minimal-blue'

    });

    

    /*全选-反选*/

    $('.checkbox-toggle').on('ifChecked', function(event){

        var _this = $(this);

        var _table = _this.closest('.table');

        _table.find("tr td input[type='checkbox']").iCheck("check");

    });

    $('.checkbox-toggle').on('ifUnchecked', function(event){

        var _this = $(this);

        var _table = _this.closest('.table');

        _table.find("tr td input[type='checkbox']").iCheck("uncheck");

    });

    

    $('.editable').editable({

        emptytext: "empty",

        params: function(params) {      //参数

            var data = {};

            data['id'] = params.pk;

            data[params.name] = params.value;

            return data;

        },

        success: function(response, newValue) {

            var res = $.parseJSON( response );

            if(res.status == 1){

                toastr.success(res.info);

            }else{

                return res.info;

            }

        }

    });

})

</script>

{/block}